//
//  Info1ViewController.m
//  markmap
//
//  Created by 甘世清 on 2024/4/24.
//

#import "Info1ViewController.h"
#import "InfoAllViewController.h"
@interface Info1ViewController ()
@property (nonatomic , strong) SQCustomButton * manbutton;
@property (nonatomic , strong) SQCustomButton * womanbutton;
@property (nonatomic ) int type;
@end

@implementation Info1ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.type = 2;
    self.view.backgroundColor = UIColor.blackColor;
    WS(weakSelf);
    if ([[UserModel share].userid isEqualToString:@"125"]) {
        self.zx_navLeftBtn.hidden = YES;
        [self zx_setRightBtnWithText:SQNSLocalString(@"跳过") clickedBlock:^(ZXNavItemBtn * _Nonnull btn) {
            InfoAllViewController * vc = [[InfoAllViewController alloc]init];
            [weakSelf SQ_pushViewControllerFull:vc];
        }];
    }else{
        
    NSString * valuue = [Manager SQ_stringForKey:@"userinfo_switch"];
    if (![valuue isEqualToString:@"1"]) {
        return;
    }
    if (!self.isEdit) {
        self.zx_navLeftBtn.hidden = YES;
        [self zx_setRightBtnWithText:SQNSLocalString(@"跳过") clickedBlock:^(ZXNavItemBtn * _Nonnull btn) {
            InfoAllViewController * vc = [[InfoAllViewController alloc]init];
            [weakSelf SQ_pushViewControllerFull:vc];
        }];
    }
    
}

}

- (void)SQ_UIViewForSelfView{
   
    for (int x = 0; x<3; x++) {
        UIView * bglineview = [[UIView alloc]init];
        if (x<2) {
            bglineview.backgroundColor = SQColor(@"#BF33FF");
        } else {
            bglineview.backgroundColor = SQColor(@"#414141");
        }
        [self.view addSubview:bglineview];
        [bglineview mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.width.mas_equalTo(SCREEN_WIDETH/3.f-4);
                    make.height.mas_equalTo(2);
                    make.left.equalTo(self.view).offset(SCREEN_WIDETH/3.f*x);
            make.bottom.equalTo(self.zx_navBar.mas_bottom);
        }];
    }
    
    UILabel * num = [[UILabel alloc]init];
    num.text = SQNSLocalString(@"2/3");
    num.font = FONT_MEDIUM(13);
    num.textColor = SQColor(@"#6B6B6B");
    [self.view addSubview:num];
    [num mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.view.mas_right).offset(-24);
            make.top.equalTo(self.zx_navBar.mas_bottom).offset(8);
    }];
    
    UIImageView * topImage = [[UIImageView alloc]init];
    topImage.image = SQGetImage(@"椭圆形");
    topImage.contentMode = UIViewContentModeScaleAspectFit;
    [self.view addSubview:topImage];
    [topImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.view).offset(12);
            make.top.equalTo(self.zx_navBar.mas_bottom).offset(10);
            make.size.mas_equalTo(68);
    }];
    UILabel * label1 = [[UILabel alloc]init];
    label1.text = SQNSLocalString(@"你好~");
    label1.textColor = UIColor.whiteColor;
    label1.font = FONT_NIHAO(32);
    [self.view addSubview:label1];
    [label1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(35);
        make.top.equalTo(self.zx_navBar.mas_bottom).offset(25);
        
    }];
    
    UILabel * num2 = [[UILabel alloc]init];
    num2.text = SQNSLocalString(@"完善一下资料吧");
    num2.font = FONT_SEMIBOLD(18);
    num2.textColor = UIColor.whiteColor;
    [self.view addSubview:num2];
    [num2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(35);
        make.top.equalTo(label1.mas_bottom).offset(8);
    }];
    UILabel * num3 = [[UILabel alloc]init];
    num3.text = SQNSLocalString(@"性别");
    num3.font = FONT_MEDIUM(17);
    num3.textColor = UIColor.whiteColor;
    [self.view addSubview:num3];
    [num3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(35);
        make.top.equalTo(num2.mas_bottom).offset(65);
    }];
    
    UILabel * num34 = [[UILabel alloc]init];
    num34.text = SQNSLocalString(@"选择后不可更改~");
    num34.font = FONT_MEDIUM(13);
    num34.textColor = SQColor(@"#6B6B6B");
    [self.view addSubview:num34];
    [num34 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(35);
        make.top.equalTo(num3.mas_bottom).offset(5);
    }];
    
   
    [self.view addSubview:self.manbutton];
    [self.view addSubview:self.womanbutton];
    [self.manbutton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(120);
        make.height.mas_equalTo(140);
        make.left.equalTo(self.view).offset(45);
        make.top.equalTo(num3.mas_bottom).offset(72);
    }];
    [self.womanbutton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(120);
        make.height.mas_equalTo(140);
        make.right.equalTo(self.view.mas_right).offset(-45);
        make.top.equalTo(num3.mas_bottom).offset(72);
    }];
    if (self.isEdit) {
        HeaderView * xiayibu = [[HeaderView alloc]init];
        xiayibu.image = @"按钮背景";
        xiayibu.text = SQNSLocalString(@"提交");
        xiayibu.colorString = @"#FFFFFF";
        [xiayibu.btn addTarget:self action:@selector(SQ_tijiaoButton) forControlEvents:UIControlEventTouchUpInside];
        xiayibu.font = FONT_MEDIUM(18);
        [self.view addSubview:xiayibu];
        [xiayibu mas_updateConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self.view);
            make.width.mas_equalTo(SCREEN_WIDETH-110);
            make.height.mas_equalTo(48);
            make.bottom.equalTo(self.view.mas_bottom).offset(-100-FootHeight);
        }];
    } else {
        HeaderView * xiayibu = [[HeaderView alloc]init];
        xiayibu.image = @"下一步";
        [xiayibu.btn addTarget:self action:@selector(SQ_tijiaoButton) forControlEvents:UIControlEventTouchUpInside];
        xiayibu.font = FONT_MEDIUM(18);
        [self.view addSubview:xiayibu];
        [xiayibu mas_updateConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self.view);
            make.size.mas_equalTo(72);
            make.bottom.equalTo(self.view.mas_bottom).offset(-88-FootHeight);
        }];
    }
   
    
   
    WS(weakSelf);
    [self.manbutton setTouchBlock:^(SQCustomButton * _Nonnull button) {
        weakSelf.manbutton.image =  SQGetImage(@"nanzhuang");
        weakSelf.manbutton.textColor = SQColor(@"#41AAFF");
        weakSelf.womanbutton.image = SQGetImage(@"nvsheng-2");
        weakSelf.womanbutton.textColor = SQColor(@"6B6B6B");
        weakSelf.type = 1;
    }];
    [self.womanbutton setTouchBlock:^(SQCustomButton * _Nonnull button) {
        weakSelf.womanbutton.image =  SQGetImage(@"nvsheng");
        weakSelf.womanbutton.textColor = SQColor(@"#FF4184");
        weakSelf.manbutton.image = SQGetImage(@"nanzhuang-2");
        weakSelf.manbutton.textColor = SQColor(@"6B6B6B");
        weakSelf.type = 2;
    }];
    
}
-(void)SQ_tijiaoButton{
    [YJProgressHUD SQ_showMsgWithoutView:@""];
    NSMutableDictionary * dic = [[NSMutableDictionary alloc]init];
    [dic setObject:@(self.type) forKey:@"gender"];
    [HttpTool post:Url5 paramDic:dic successBlock:^(BaseModel * _Nonnull httpModel) {
        UserModel * model = [UserModel share];
        model.gender = self.type;
        [UserModel updateLocalUserModel:model];
        if (self.isEdit) {
            [self SQ_popViewVC];
        } else {
            InfoAllViewController * vc = [[InfoAllViewController alloc]init];
            [self SQ_pushViewControllerFull:vc];
        }
    } andFailBloc:^(BaseModel * _Nonnull httpModel, NSError * _Nullable error) {
        [YJProgressHUD showMsgWithoutView:httpModel.message];
    }];
     
}



- (SQCustomButton *)manbutton{
    if (!_manbutton) {
        _manbutton = [[SQCustomButton alloc]initType:SQCustomButtonTopImageType imageSize:CGSizeMake(120, 140) midmargin:-40];
        _manbutton.text =SQNSLocalString(@"男生");
        _manbutton.textColor =  SQColor(@"#6B6B6B");
        _manbutton.font = FONT_MEDIUM(17);
        _manbutton.image = SQGetImage(@"nanzhuang-2");
    }
    return _manbutton;
}

- (SQCustomButton *)womanbutton{
    if (!_womanbutton) {
        _womanbutton = [[SQCustomButton alloc]initType:SQCustomButtonTopImageType imageSize:CGSizeMake(120, 140) midmargin:-40];
        _womanbutton.text =SQNSLocalString(@"女生");
        _womanbutton.textColor = SQColor(@"#FF4184");
        _womanbutton.font = FONT_MEDIUM(17);
        _womanbutton.image = SQGetImage(@"nvsheng");
        
    }
    return _womanbutton;
}

@end
